# coding: utf-8
from PySide6.QtGui import QColor
from qfluentwidgets import (qconfig, QConfig, ConfigItem, OptionsConfigItem, BoolValidator, OptionsValidator, Theme,
                            ColorConfigItem, ColorValidator, RangeConfigItem, RangeValidator)

from .setting import CONFIG_FILE
from .utils import isWin11


class Config(QConfig):
    """ Config of application """
    # 壁纸设置
    wallpaperEnabled = ConfigItem("Wallpaper", "Enabled", False, BoolValidator())
    wallpaperImage = ConfigItem("Wallpaper", "Path", ':/edge-tts/image/single/bg.png')
    wallpaperLightColor = ColorConfigItem("Wallpaper", "LightColor", QColor(255, 255, 255))
    wallpaperDarkColor = ColorConfigItem("Wallpaper", "DarkColor", QColor(51, 51, 51))
    wallpaperOpacity = RangeConfigItem("Wallpaper", "Opacity", 150, RangeValidator(0, 255))
    # 应用
    micaEnabled = ConfigItem("MainWindow", "MicaEnabled", isWin11(), BoolValidator())
    dpiScale = OptionsConfigItem(
        "MainWindow", "DpiScale", "Auto", OptionsValidator([1, 1.25, 1.5, 1.75, 2, "Auto"]), restart=True)

    # 应用设置
    checkUpdateAtStartUp = ConfigItem("Application", "CheckUpdateAtStartUp", True, BoolValidator())


cfg = Config()
cfg.themeMode.value = Theme.AUTO
qconfig.load(CONFIG_FILE, cfg)
